#define _CRT_SECURE_NO_WARNINGS 1

#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

int main()
{
	int arr[5] = { 0 };
	for (int i = 0; i < 5; i++)
	{
		scanf("%d", &arr[i]);
	}
	int sum = 0;

	for (int i = 0; i < 5; i++)
	{
		sum += arr[i];
	}

	int ave = sum / 5 + sum % 5;
	int arr1[5] = { 0 };
	int j = 0;
	for (int i = 0; i < 5; i++)
	{
		if (arr[i] < ave)
		{
			arr1[j] = arr[i];
			j++;
		}
	}
	int a = 0;



	for (int i = 0; i < j; i++)
	{
		if (arr1[i] > arr1[i + 1] && arr1[i + 1] != 0)
		{
			a = arr1[i];
		}
	}

	printf("%d", a);
	return 0;
}